import { createApp } from "vue";
import App from "./App.vue";
import "./style.css";
import { router } from "@/router/index.js";
import { globalComponent } from "./components";
import store from "./store";

createApp(App)
  .use(router)
  .use(globalComponent)
  .use(store)
  .mount("#app");

import NetworkListener from "@/utils/NetworkListener";
import { useRequestStore } from "@/store/state/request-store";
import { v4 } from "uuid";
import { buildRequest } from "@/utils/request-util";

const requestStore = useRequestStore();
const networkListener = new NetworkListener();
networkListener.addListener({
  id: v4(),
  cb(fullRequest) {
    requestStore.pushRequest(buildRequest(fullRequest));
  },
});
requestStore.setListener(networkListener);
